<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自我介绍</title>
</head>
<style>
    .container {
        margin: 100px auto;
        width: 800px;
    }
    
    .td_left {
        width: 100px;
        text-align: justify;
        text-align-last: justify;
        line-height: 50px;
    }

    .td_right {
        width: 200px;
        padding-left: 20px;
    }

</style>
<body>
    <div class="container">
        <form action="#" id="myForm" onsubmit="return login()">
            <table align="center" width="500px">
                <tr>
                    <td class="td_left">用户名</td>
                    <td class="td_right"><input type="text" name="username" id="username" size="30px" onblur="check()"></td>
                </tr>
                <tr>
                    <td class="td_left">密码</td>
                    <td class="td_right"><input type="password" name="password" id="password" size="30px"></td>
                </tr>
                <tr>
                    <td class="td_left">性别</td>
                    <td class="td_right">
                        <input type="radio" name="sex" id="male">男
                        <input type="radio" name="sex" id="female" style="margin-left: 40px">女
                    </td>
                </tr>
                <tr>
                    <td class="td_left">学历</td>
                    <td class="td_right"><select name="edu" id="edu">
                        <option value="0" selected>请选择...</option>
                        <option value="1" >本科</option>
                        <option value="2" >专科</option>
                    </select></td>
                </tr>
                <tr>
                    <td class="td_left">自我介绍</td>
                    <td class="td_right"><textarea name="intro" id="intro" cols="33" rows="10"></textarea></td>
                </tr>
                <tr>
                    <td align="center" colspan="2"><input type="submit" value="提交"></td>
                </tr>
            </table>
        </form>

    </div>
    <script>
        function check() {
            var username = document.getElementById("username").value;
            console.log(username);
            if (username !== 'admin') {
                alert("账号必须为admin！");
                return false;
            }
            return true;
        }

        function login() {
            if (check()) {
                var content = document.getElementById("intro").value;
                alert("自我介绍：" + content);
                return true;
            } else {
                alert("表单有错误！");
                return false;
            }
        }
    </script>

</body>

</html>